<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>借阅列表</title>
    <style>
        body {
            margin: 0;
            padding: 40px 20px;
            background: linear-gradient(135deg, #0f2027, #203a43, #2c5364);
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            color: #e0f7fa;
            display: flex;
            flex-direction: column;
            align-items: center;
            min-height: 100vh;
        }

        h1 {
            font-size: 2.5rem;
            color: #00f7ff;
            text-shadow: 0 0 10px #00f7ff;
            margin-bottom: 30px;
        }

        nav {
            margin-bottom: 30px;
        }

        nav a {
            color: #00e6e6;
            font-weight: bold;
            margin: 0 10px;
            text-decoration: none;
            font-size: 1.1rem;
            transition: color 0.3s;
        }

        nav a:hover {
            color: #ffffff;
            text-shadow: 0 0 8px #00f7ff;
        }

        a.button {
            display: inline-block;
            margin: 10px 0 30px;
            padding: 10px 20px;
            background: linear-gradient(90deg, #00f7ff, #01c8ff);
            color: #001f29;
            border-radius: 10px;
            font-weight: bold;
            text-decoration: none;
            transition: transform 0.2s, box-shadow 0.3s;
        }

        a.button:hover {
            transform: scale(1.05);
            box-shadow: 0 0 12px #00f7ff;
        }

        table {
            width: 90%;
            max-width: 1000px;
            border-collapse: collapse;
            box-shadow: 0 0 15px rgba(0, 255, 255, 0.2);
            background-color: rgba(20, 30, 40, 0.95);
            border-radius: 12px;
            overflow: hidden;
        }

        th, td {
            border-bottom: 1px solid #334d5c;
            padding: 14px 16px;
            text-align: center;
        }

        th {
            background-color: #003d4d;
            color: #00e6ff;
            font-weight: bold;
            font-size: 1rem;
        }

        tr:hover {
            background-color: rgba(0, 247, 255, 0.1);
        }

        td a {
            color: #00ffff;
            text-decoration: none;
            transition: color 0.2s;
        }

        td a:hover {
            color: #ffffff;
            text-shadow: 0 0 5px #00f7ff;
        }

        @media (max-width: 768px) {
            table, thead, tbody, th, td, tr {
                display: block;
            }

            tr {
                margin-bottom: 15px;
                border: 1px solid #00f7ff33;
                border-radius: 10px;
                padding: 10px;
                background-color: #102733;
            }

            td {
                text-align: right;
                position: relative;
                padding-left: 50%;
            }

            td::before {
                content: attr(data-label);
                position: absolute;
                left: 10px;
                width: 45%;
                font-weight: bold;
                color: #00e6ff;
            }

            th {
                display: none;
            }
        }
    </style>
</head>
<body>
    <h1>借阅列表</h1>
    <nav>
        <a href="/">首页</a> |
        <a href="/borrows">借阅管理</a>
    </nav>
    <a href="/borrows/add" class="button">➕ 添加借阅记录</a>

    <table>
        <thead>
            <tr>
                <th>ID</th>
                <th>图书</th>
                <th>用户</th>
                <th>借阅日期</th>
                <th>归还日期</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            {{range .Borrows}}
            <tr>
                <td data-label="ID">{{.ID}}</td>
                <td data-label="图书">{{.Book.Title}}</td>
                <td data-label="用户">{{.User.Name}}</td>
                <td data-label="借阅日期">{{.BorrowDate.Format "2006-01-02"}}</td>
                <td data-label="归还日期">
                    {{if .ReturnDate}}{{.ReturnDate.Format "2006-01-02"}}{{else}}-{{end}}
                </td>
                <td data-label="操作">
                    {{if not .ReturnDate}}
                    <a href="/borrows/return/{{.ID}}">归还</a> |
                    {{end}}
                    <a href="/borrows/delete/{{.ID}}" onclick="return confirm('确定删除？')">删除</a>
                </td>
            </tr>
            {{else}}
            <tr><td colspan="6">暂无数据</td></tr>
            {{end}}
        </tbody>
    </table>
</body>
</html>
